<!--
 * @作者: kerwin
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
   
    <script>
        class Receiver{
            //接受类
            execute(){
                console.log("接收者执行请求")
            }
        }

        class Command{
            constructor(receiver){
                this.receiver = receiver
            }
            //命令类
            execute(){
                console.log("命令对象=>接受者如何处理")
                this.receiver.execute()
            }
        }

        class Invoker{
            //发布类
            constructor(command){
                this.command =command
            }
            order(){
                console.log("发布请求")
                this.command.execute()
            }
        }

        const order = new Command(new Receiver())

        const client = new Invoker(order)

        client.order()
    </script>
</body>

</html>